﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SzCourt.Logic.NBL.DBEntities;
using SzCourt.Logic.BLL;

namespace SzCourt.WebSite.manager
{
    public partial class ReplayAdd : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!AdminSession.SessionBox.CheckUserSession())
            {
                Response.Redirect("/manager/login.aspx");
            }
            if (!this.IsPostBack)
            {
                getList();
            }
        }

        private void getList()
        {

            PreCase bll = new PreCase();
            List<pPreCaseAutoReply> result = (List<pPreCaseAutoReply>)bll.GetCaseAutoReplyList();
            if (result != null)
            {
                this.rptDataList.DataSource = result;
                this.rptDataList.DataBind();
            }
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            pPreCaseAutoReply param = new pPreCaseAutoReply();
            param.AutoReplyTitle = this.txtTitle.Value;
            param.AutoReplyContent = this.txtAutoReplyContent.Value;

            PreCase  bll = new PreCase();
            bool result = (bool)bll.AddCaseAutoReply(param);
            if (result)
            {
                this.divMessage.InnerHtml = "新增案由自动回复成功！";
                getList();
            }
            else
            {
                this.divMessage.InnerHtml = "新增案由自动回复失败！";
            }
        }
    }
}